import 'package:flutter/material.dart';

class RoomDetailPage extends StatefulWidget {
  final String roomId;

  const RoomDetailPage({super.key, required this.roomId});

  @override
  State<RoomDetailPage> createState() => _RoomDetailPageState();
}

var bottomButtonTextStyle = const TextStyle(color: Colors.white, fontSize: 18);

class _RoomDetailPageState extends State<RoomDetailPage> {
  bool isLike = false; // 是否收藏
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('房屋详情id：${widget.roomId}'),
        actions: [
          IconButton(onPressed: () {}, icon: const Icon(Icons.share)),
        ],
      ),
      body: Stack(
        children: [
          ListView(
            children: const [Text('eeee')],
          ),
          Positioned(
              width: MediaQuery.of(context).size.width,
              height: 100,
              bottom: 0,
              child: Container(
                color: Colors.grey.shade200,
                height: 300,
                child: Row(
                  children: [
                    GestureDetector(
                      child: Container(
                        height: 50,
                        width: 60,
                        margin: const EdgeInsets.only(right: 10),
                        child: GestureDetector(
                          onTap: () => setState(() {
                            isLike = !isLike;
                          }),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Icon(
                                isLike ? Icons.star : Icons.star_border,
                                color: isLike ? Colors.green : Colors.black,
                                size: 24,
                              ),
                              Text(
                                isLike ? '已收藏' : '收藏',
                                style: const TextStyle(fontSize: 12),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: (() => Navigator.pushNamed(context, 'test')),
                        child: Container(
                          height: 50,
                          margin: const EdgeInsets.only(right: 5),
                          decoration: BoxDecoration(
                            color: Colors.cyan,
                            borderRadius: BorderRadius.circular(8),
                          ),
                          child: Center(
                            child: Text('联系房东', style: bottomButtonTextStyle),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: (() => Navigator.pushNamed(context, 'test')),
                        child: Container(
                          height: 50,
                          margin: const EdgeInsets.only(right: 6),
                          decoration: BoxDecoration(
                            color: Colors.green,
                            borderRadius: BorderRadius.circular(8),
                          ),
                          child: Center(
                            child: Text('预约看房', style: bottomButtonTextStyle),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ))
        ],
      ),
    );
  }
}
